//
//  ManageTraineesViewController.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/19.
//

#import "ManageTraineesViewController.h"
#import "ManagementStudentView.h"
#import "ManagementStudentCell.h"

#import "AddStudentViewController.h"

#import "SendGroupMessageViewController.h"

@interface ManageTraineesViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    ManagementStudentView *_ManagementStudentView;
    UIScrollView *_ScrollView;
    UITableView *_Tabview;
    ManagementStudentCell *Cell;
}
@end

@implementation ManageTraineesViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    //隐藏头部view
    self.navigationController.navigationBar.hidden = YES;
    NavigationHeadView *navgationheadv = [[NavigationHeadView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, SafeAreaTopHight)];
    navgationheadv.titlelabel.text = @"管理学员";
    navgationheadv.titlelabel.textColor = [UIColor blackColor];
    navgationheadv.backbtn.hidden = NO;
    [navgationheadv.backbtn addTarget:self action:@selector(returnback) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:navgationheadv];

    _ManagementStudentView = [[ManagementStudentView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHight, APPwidth, 200)];
    [_ManagementStudentView.searchBtn addTarget:self action:@selector(searchBarBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [_ManagementStudentView.duanxinBtn addTarget:self action:@selector(duanxinBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_ManagementStudentView];
    

    _ScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHight+120, APPwidth, APPheight-SafeAreaTopHight-120)];
    _ScrollView.contentSize = CGSizeMake(APPwidth*8, APPheight-SafeAreaTopHight-120);
    _ScrollView.backgroundColor = rgba(244, 247, 252, 1);
    _ScrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    _ScrollView.bounces = true; // 表明当前滑动是否有反弹效果
    _ScrollView.pagingEnabled = NO; // 分页效果
    _ScrollView.showsVerticalScrollIndicator = NO;
    _ScrollView.scrollEnabled = true; // 使当前能够滑动和不能滑动
    _ScrollView.pagingEnabled = YES;
    [self.view addSubview:_ScrollView];

    
    
    _Tabview  = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, APPheight)];
    _Tabview.delegate = self;
    _Tabview.dataSource = self;
    _Tabview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_ScrollView addSubview:_Tabview];
    
}
#pragma mark - UITableView DataSource

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 140;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString * str = @"cell";
    
    Cell  = [tableView dequeueReusableCellWithIdentifier:str];
    if (Cell == nil) {
        
        Cell = [[ManagementStudentCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:str];
    }
    
//    Cell.nameLab.text = @"学员:小芒果";
    
    Cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return Cell;
}

-(void)searchBarBtnClick{
    AddStudentViewController *vc = [[AddStudentViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)duanxinBtnClick{
    SendGroupMessageViewController *vc = [[SendGroupMessageViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];

}
-(void)returnback{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark -视图即将出现
-(void)viewWillAppear:(BOOL)animated{
        
    ((TabbarController *)self.tabBarController).tabBarView.hidden = YES;
    
}

@end
